Repository navigation
Conversation
There was a problem hiding this comment.
@lxy-9602, I left some comments for the failing clang-tidy check, the concurrency and executor contracts, and coverage of simultaneous queries. PTAL.
| for (int32_t iteration = 0; iteration < 16; ++iteration) { | ||
| const int32_t query_id = thread_id * 16 + iteration; | ||
| const int32_t parity = query_id % 2; | ||
| const float query_score = static_cast<float>(query_id + 3); |
There was a problem hiding this comment.
Fix the clang-tidy failure on this declaration. The clang-debug-x86_64 job passes CTest, then fails check-clang-tidy with modernize-use-auto here. const auto query_score = static_cast<float>(query_id + 3); preserves the type and clears the diagnostic. CI log
|
|
||
| /// @return true if the reader is thread-safe; false otherwise. | ||
| /// @return true if the same reader supports concurrent queries; false otherwise. | ||
| /// Query arguments must not be modified during a call, and user callbacks and memory pools |
There was a problem hiding this comment.
Account for query lifetime after an exceptional exit. UnionGlobalIndexReader can unwind on an Executor::Add() or future.get() exception while accepted tasks still hold the original search object or its pre-filter. TestDeferredTaskOwnsActionAfterEarlierFutureThrows demonstrates that a queued task can run after the visit unwinds. A caller following the new wording can reuse the query or release objects borrowed by its pre-filter at that point, while a shard may still access them. Please drain accepted tasks before unwinding, or document that the arguments and callback state must remain valid and immutable until the accepted work finishes.
| /// @return true if the reader is thread-safe; false otherwise. | ||
| /// @return true if the same reader supports concurrent queries; false otherwise. | ||
| /// Query arguments must not be modified during a call, and user callbacks and memory pools | ||
| /// used concurrently must be thread-safe. Reader lifetime must cover all outstanding calls. |
There was a problem hiding this comment.
Document the concurrency requirement for custom file systems. A multi-shard search can lazily open index files through the same GlobalIndexFileManager and call FileSystem::Open() concurrently. For example, FullTextGlobalIndexReader serializes opening within a shard with its own mutex, and different shards have distinct mutexes. An IsThreadSafe() result of true therefore still requires the supplied storage implementation to support the calls made concurrently. Please state this on the file_system parameter of both Create() overloads, and include custom index I/O in the reader's concurrency contract.
| } | ||
| }); | ||
| if (searches.size() <= 1) { | ||
| if (!executor_ || searches.size() <= 1) { |
There was a problem hiding this comment.
The null-executor fallback is unreachable through Create(). That is the only construction path and it stores the non-null result of GetOrCreateExecutor(), including when the builder is given WithExecutor(nullptr). Invalid thread counts fail before SearchSplits() runs. Please drop this branch and the corresponding behavior claim, or expose a supported serial path and exercise it with at least two eligible splits.
| /// Sets the executor that searches splits in parallel and reads manifests. If not set, each | ||
| /// read creates an executor with `global-index.thread-num` threads, which defaults to the | ||
| /// number of CPUs. | ||
| /// Sets the executor that searches splits in parallel and reads manifests. If not set, |
There was a problem hiding this comment.
Document the executor re-entry restriction at the public entry point. If a task on a one-worker executor calls ExecuteLocal() with that same executor and two eligible splits, Read() queues both shard searches behind the caller and waits for them. Builder users can hit this deadlock without ever calling GlobalIndexReader::IsThreadSafe(). Please document the restriction beside WithExecutor() and in the user guide, including planning and filtering operations that can wait for manifest work on the same pool.
| std::vector<std::future<void>> workers; | ||
| for (int32_t thread_id = 0; thread_id < 4; ++thread_id) { | ||
| workers.push_back(std::async(std::launch::async, [reader, ready, thread_id]() { | ||
| ready.wait(); |
There was a problem hiding this comment.
Make the test observe overlapping queries with different filters. The start promise releases the callers. Each query can complete before the next enters while still satisfying every assertion. All four callers also use the same filter parity in a given iteration (thread_id * 16 + iteration), which can hide filter reuse when they progress together. Can one fake shard hold its first visit until a second visit with the opposite filter arrives, with a bounded wait? In the executor-backed case, also verify that shard work is submitted to the injected executor.
| /// may rank rows of a shard, live rows are loaded on the visiting thread before it fans out to | ||
| /// the shards, so a load that reads manifests on `executor` never waits for it from one of its | ||
| /// own threads. | ||
| /// the shards. Callers must run outside `executor` when loading or searching waits for tasks |
There was a problem hiding this comment.
The live-rows supplier can still run on a shard worker after preloading. CreateUnion() passes the same supplier to each LiveRowGlobalIndexReader, and the shard visits invoke it again. With two shards and a one-worker executor, an uncached supplier that submits manifest work to that executor and waits can deadlock even when the query starts on an external thread. Please document that after preloading, shard-side supplier calls must return without waiting for work on executor. CacheLiveRows() provides that behavior for a snapshot-scoped loader.
Purpose
Clarify the conditions under which a global index reader can be shared across query threads, and add regression coverage for concurrent queries through Union, LiveRow, and Offset wrappers.
Document supplier synchronization requirements and executor behavior. Also handle a null executor in full-text shard searches by evaluating the shards sequentially.
Tests
API and Format
Clarifies public API documentation without changing API signatures, storage formats, or protocols.
Documentation
Document reader concurrency requirements, nested-executor deadlock risks, and the distinction between outer query executors and Bitmap/BTree private pools.
Generative AI tooling
Generated-by: OpenAI Codex (GPT-6)